#include "stdafx.h"
#include "ProgressBar.h"
#include "..\..\..\..\EdgeGraphics\HUD.h"
#include "..\..\..\..\EdgeGraphics\Fonts.h"
#include "..\..\..\..\EdgeGraphics\BitmapFont.h"

ProgresBar::ProgresBar(void)
{
	// set default values for width and height
	clientRect.setWidth(100.f);
	clientRect.setHeight(50.f);
}

/*virtual*/ ProgresBar::~ProgresBar(void)
{

}

/*virtual*/ void ProgresBar::Update(float dt) /*override*/
{
	// call the inherited function
	UiElement::Update(dt);
}

/*virtual*/ void ProgresBar::Draw(void) /*override*/
{
	BitmapFont* arial = Fonts::GetInstance()->arial_small;
	arial->Draw(text.c_str(), (int)clientRect.left, (int)clientRect.top, 1.f, vector_4::white);
	
	Vector2 nameSize = arial->MeasureString(text.c_str());

	Hud::GetInstance()->DrawRectangle((int)clientRect.left + (int)nameSize.x, (int)clientRect.top - (int)nameSize.y, int(clientRect.getWidth() * getPercentage()), int(clientRect.getHeight()), front_color);
	Hud::GetInstance()->DrawRectangle((int)clientRect.left + (int)nameSize.x, (int)clientRect.top - (int)nameSize.y, (int)clientRect.getWidth(), (int)clientRect.getHeight(), back_color);
}